package worker;

import cn.cityre.tools.crestat.BaseStatWorker;
import cn.cityre.tools.db.DataSourceContextHolder;
import cn.cityre.tools.db.DynamicDataSource;
import cn.cityre.mapper.ManagerAiMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author S.Z.Y
 * @date 2019-08-07 14:22
 */
@Service
public class WxNewsWorker extends BaseStatWorker {

    private final static Logger log = LoggerFactory.getLogger(WxNewsWorker.class);

    @Override
    protected Runnable createWorker(int idx) {
        return new WxNewsWorker.WorkerTask();
    }

    @Autowired
    protected WxNewsWorker(DynamicDataSource dynamicDataSource) {
        super(dynamicDataSource);
    }

    @Autowired
    private ManagerAiMapper managerAiMapper;

    class WorkerTask implements Runnable {
        @Override
        public void run() {
            log.info("WxNewsWorker start");
            DataSourceContextHolder.setDbType("hotline");
            int cnt = managerAiMapper.countComment("gd.weixin.zhibo");
            System.out.println(cnt);
        }
    }
}
